'use strict'

const config = require('../config/config.js')

const {cors, parsebody, tofile} = require('titbit-toolkit')

let cr = new cors(config.cors || {
  allow: '*',
  allowEmptyReferer: true
})

module.exports = [
  {
    pre: true,
    middleware: cr.mid()
  },

  {
    middleware: new parsebody,
    method: [
      'POST', 'PUT', 'DELETE'
    ]
  },

  {
    middleware: new tofile,
    method: [
      'POST', 'PUT'
    ]
  }
]
